public class Solution {
    public boolean hasGroupsSizeX(int[] deck) {
        if (deck == null || deck.length <= 1) return false;
        int[] counter = new int[10000];
        for (int i : deck) {
            counter[i]++;
        }
        int x = 0;
        for (int i : counter) {
            if (i > 0) {
                x = gcb(x, i);
                if (x == 1) return false;
            }
        }
        return x >= 2;
    }

    private int gcb(int x, int y) {
        int b = x % y;
        return b == 0 ? y : gcb(y, b);
    }

    public static void main(String[] args) {
        int[] arr = {1, 2};
        Solution s = new Solution();
        System.out.println(s.hasGroupsSizeX(arr));
    }
}

